/**
 * 定义站点模块
 */
(function(window, angular, undefined){

	var monitorStationModule = angular.module('water.entity.monitorStation',['waterCommon']);
	
	monitorStationModule.service('$monitorStationService',function($q,$waterDataCommon){
		
		/**
		 * 查询站点列表
		 * {
		 * 	WWTP_ID:'',
		 *  FLOW_TYPE:'',
		 *  WATER_TYPE:'',
		 *  STATION_ID:'',
		 *  BUILD_STATUS:'',
		 *  stationName:'',
		 * }
		 */
		this.getList = function(queryObj){
			var promise = $waterDataCommon.post("/MonitorStation/getList",queryObj);
			return promise;
		}
		/**
		 * 获取列表域,作为下拉数据
		 */
		this.getDomainList = function(queryObj){
			var deferred = $q.defer();
			var promise = deferred.promise;
			this.getList(queryObj).then(function(d){
				var domainData = [];
				for(var i=0;i<d.length;i++){
					domainData.push({
						k:d[i].EXP_NO,
						v:d[i].NAME
					});
				}
				deferred.resolve(domainData);
			});
			return promise;
		}
		/**
		 * 获取有上级公司的站点列表
		 * {
		 * WWTP_ID:
		 * FLOW_TYPE:
		 * WATER_TYPE:
		 * STATION_ID:
		 * BUILD_STATUS:
		 * STATION_NAME:
		 * stationStatus:
		 * DISTRICT:
		 * }
		 */
		this.getListWithCompany = function(queryObj){
			var promise = $waterDataCommon.post("/MonitorStation/getListWithCompany",queryObj);
			return promise;
		}
		/**
		 * 统计站点在线状态
		 * {
		 * 	WWTP_ID:'',
		 *  FLOW_TYPE:'',
		 *  WATER_TYPE:'',
		 *  STATION_ID:'',
		 *  BUILD_STATUS:'',
		 *  stationName:'',
		 *  stationStatus:''
		 * }
		 */
		this.getStatusStatistics = function(queryObj){
			var promise = $waterDataCommon.post("/MonitorStation/getStatusStatistics",queryObj);
			return promise;
		}
		/**
		 * 新建站点
		 */
		this.createModel = function(data){
			var promise = $waterDataCommon.createModel("BC_SITE_INFO",data);
			return promise;
		}
		/**
		 * 更新站点
		 */
		this.updateModel = function(data){
			var promise = $waterDataCommon.updateModel("BC_SITE_INFO",data);
			return promise;
		}
		
		/**
		 * 获取站点model
		 */
		this.getModel = function(key){
			var promise = $waterDataCommon.getModel("BC_SITE_INFO",key);
			return promise;
		}
		
	})
}(window, angular));